package com.mf.utils;

import org.springframework.beans.BeanUtils;

import java.lang.reflect.InvocationTargetException;

/**
 * @Author: lmf
 * @Create: 2025/4/1 21:22
 * @module 控制层工具类
 */
public class UtilConverter {
    /**
     * 将实体类转成Bo
     */
    public static <T,S> T converter(S source,Class<T> targetClass){
        try {
            final T target = targetClass.getDeclaredConstructor().newInstance();
            BeanUtils.copyProperties(source, target);
            return target;
        } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            throw new RuntimeException(e);
        }

    }
}
